package cn.tedu.start.controller.petcontroller;

import cn.tedu.commons.response.JsonResult;
import cn.tedu.pojo.pet.dto.PetDetailsDTO;
import cn.tedu.service.petcommodity.IPetDetailsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "4.宠物详情列表")
@RestController
@RequestMapping("/petdetails")
public class PetDetailsController {
    @Autowired
    private IPetDetailsService petDetailsService;

    @ApiOperation("管理员添加宠物详情")
    @PostMapping("/add")
    public JsonResult addDetails(@RequestBody PetDetailsDTO petDetailsDTO){
        petDetailsService.addDetails(petDetailsDTO);
        return JsonResult.ok("添加宠物详情成功！");
    }

    @ApiOperation("管理员修改宠物详情")
    @GetMapping("/update/details")
    public JsonResult updateDetails(PetDetailsDTO petDetailsDTO){
        petDetailsService.updateDetails(petDetailsDTO);
        return JsonResult.ok("修改宠物详情成功");
    }

    @ApiOperation("管理员设置详情是否启用")
    @GetMapping("/update/isdelete")
    public JsonResult updateIsDelete(Long id,Integer isDelete){
        System.out.println(id);
        System.out.println(isDelete);

        petDetailsService.updateIsDelete(id,isDelete);
        return JsonResult.ok("修改宠物详情启用状态成功");
    }
}
